import 'package:event_bus/event_bus.dart' show EventBus;

///
/// EventBusUtil
/// Created by gpuxiao on 2025/7/1.
/// description:eventbus类，通过这个类发送数据到ui层
/// usage:
/// 发送：EventBusUtil.getInstance().fire(DataEvent(DataType.UDP,item));
/// 接收： EventBusUtil.getInstance().on().listen((event) {
///       DataEvent dataEvent = event;
/// });
///
class EventBusUtil {
  static late EventBus _eventBus;
  static bool init = false;

  static EventBus getInstance() {
    if (!init) {
      init = true;
      _eventBus = EventBus();
    }
    return _eventBus;
  }
}

///
/// DataEvent
/// description:事件数据返回
class DataEvent {
  int type; //类型
  dynamic data;//数据

  DataEvent(this.type, this.data);
}

///
/// NativeEvent
/// description:原生和Flutter层事件返回
class NativeEvent{
  String type;//类型
  dynamic data;//数据
  NativeEvent(this.type,this.data);
}

///
/// FlutterCallEvent
/// description:Flutter发送事件
class FlutterCallEvent{
  String type;//类型
  dynamic data;//数据
  FlutterCallEvent(this.type,this.data);
}
